#include "user_rom.h"
#include "flash.h"

u8 UR_IsFirstUse(void)
{
    u8 temp = 0xff;
    for (int i = 0; i < USER_ROM_SIZE; i++)
    {
        temp = Flash_ReadByte(USER_BEGING_ADDR + i);
        if (temp != 0x00)
            return 0;
    }
    return 1;
}

void UR_WriteSystemState(SystemState *sys)
{
    Flash_WriteBuffer(USER_BEGING_ADDR, (u8 *)sys, sizeof(SystemState));
}

void UR_ReadSystemState(SystemState *psys)
{
    Flash_ReadBuffer(USER_BEGING_ADDR, (u8 *)psys, sizeof(SystemState));
}